
	
	// 新增按钮初始化
	function addStationInit() {
		clearInput();
		$("#edit_station_btn").hide();
	    $("#submit_station_btn").show();
	    
	    $("#stationInfoTable input[type='text']").each(function(e){
	    	$(this).removeAttr("readonly");
	    	$(this).removeAttr("style");
	    	$(this).css("background-color","");
		 });
	    $("#station_jfDateStr_edit").attr("readonly","readonly");
	    $("#station_jfDateStr_edit").css("background-color","white");
	    $("#station_jfDateStr_edit").removeAttr("disabled");
		$("#managerStation_div").modal("show");
		$("#managerStation_title").text("新增基站");
		$("#managerStation_color").attr("class","portlet box green");
		<!-- 下拉框处理 -->
		$("#station_isTuoShou_edit").removeAttr("readonly");
		$("#station_payType_edit").removeAttr("readonly");
		$("#station_isProtocol_edit").removeAttr("readonly");
		$("#station_isBeiWang_edit").removeAttr("readonly");	
		$("#station_cityArea_edit").removeAttr("readonly");	
		<!-- 下拉框处理结束 -->
	};

	// 查看按钮初始化
	function lookStationInit(item) {
		clearInput();
		$("#edit_station_btn").show();
	    $("#submit_station_btn").hide();
	    $("#stationInfoTable input[type='text']").each(function(e){
	    	$(this).attr("readonly","readonly");
	    	$(this).attr("style","border:0px");
	    	$(this).css("background-color",$(this).parents('td').css('background-color'));
		 });
	    $("#station_jfDateStr_edit").attr("disabled", "disabled");
		$("#managerStation_title").text("查看基站详情");
		$("#managerStation_color").attr("class","portlet box blue");
	    var tableRow = item.parents('tr')[0];
	    var idTh = $(tableRow).children().get(0);
	    $.post("station/getStationById", 
			{ 
				id: $(idTh).text()
			}, 
			function(json){
				for(var index in json.data){
					var val = json.data[index];
					if(typeof($("#station_"+index+"_edit")) != "undefined"){
						$("#station_"+index+"_edit").val(json.data[index]);
						<!-- 下拉框处理 -->
						if(index=='isTuoShou'){
							$("#station_"+index+"_edit").val(json.data[index]);
						}
						if(index=='payType'){
							$("#station_"+index+"_edit").val(json.data[index]);
						}
						if(index=='isProtocol'){
							$("#station_"+index+"_edit").val(json.data[index]);
						}
						if(index=='isBeiWang'){
							$("#station_"+index+"_edit").val(json.data[index]);
						}	
						if(index=='cityArea'){
							$("#station_"+index+"_edit").val(json.data[index]);
						}
						<!-- 下拉框处理结束 --> 					  					
					}
				}
				$("#managerStation_div").modal("show");
				<!-- 付款类型 -->
				<!-- 下拉框处理 --> 
				$("#station_isTuoShou_edit").attr("readonly","readonly");
				$("#station_payType_edit").attr("readonly","readonly");
				$("#station_isProtocol_edit").attr("readonly","readonly");
				$("#station_isBeiWang_edit").attr("readonly","readonly");	
				$("#station_cityArea_edit").attr("readonly","readonly");
				<!-- 下拉框处理结束 -->
			},"json"
		);
	};

	// 修改按钮初始化
	function editStationInit() {
		$("#edit_station_btn").hide();
	    $("#submit_station_btn").show();
	    $("#stationInfoTable input[type='text']").each(function(e){
	    	$(this).removeAttr("readonly");
	    	$(this).removeAttr("style");
	    	$(this).css("background-color","");
		 });
	    $("#station_jfDateStr_edit").attr("readonly","readonly");
	    $("#station_jfDateStr_edit").css("background-color","white");
	    $("#station_jfDateStr_edit").removeAttr("disabled");
		$("#managerStation_title").text("修改基站资料");
		$("#managerStation_color").attr("class","portlet box yellow");
		<!-- 下拉框处理 -->
		<!-- 付款类型 -->
		$("#station_isTuoShou_edit").removeAttr("readonly");
		$("#station_payType_edit").removeAttr("readonly");
		$("#station_isProtocol_edit").removeAttr("readonly");
		$("#station_isBeiWang_edit").removeAttr("readonly");
		$("#station_cityArea_edit").removeAttr("readonly");
		<!-- 下拉框处理结束 -->
	};

	// 删除按钮初始化
	function deleteStationInit(item) {
		$("#station_id_delete").val("");
	    var tableRow = item.parents('tr')[0];
	    var idTh = $(tableRow).children().get(0);
	    var stationNameTh = $(tableRow).children().get(4);
	    var stationNewNumberTh = $(tableRow).children().get(1);
	    var id = $(idTh).text();
	    $("#station_id_delete").val(id);
	    var message = "您确定要删除编号:"+id+",名称:"+$(stationNameTh).text()+",新序号:"+$(stationNewNumberTh).text()+",的基站吗?(本操作不可恢复)"
	    $("#deleteStation_p").text(message);
	    $("#deleteStation_div").modal("show");
	};


	//简单校验用户输入
	function submit_validation(){
		var obj = new Object();
		$("#stationInfoTable input[type='text']").each(function(e){
		    var stationId = $(this).attr("id");
		    var idArray = stationId.split('_');
		    obj[idArray[1]] = $(this).val().trim();
		 });
		var id = $("#station_id_edit").val();
		$("#stationInfoTable select").each(function(e){
		    var stationId = $(this).attr("id");
		    var idArray = stationId.split('_');
		    obj[idArray[1]] = $(this).val().trim();
		 });
		if(id == ''){
			save_station(obj)
		}else{
			update_station(obj)
		}
		clearInput();
	}

	// 更新基站提交
	function update_station(obj){
		$.post("station/updateStation",obj, 
	    	function(result){
	    		if(result == -1){
					alert("系统内部错误,请与管理员联系！");
					$("#managerStation_div").modal("hide");
					$("#table_station").dataTable().fnDraw();
				}else if(result == 0){
					alert("修改基站成功！");
					$("#managerStation_div").modal("hide");
					$("#table_station").dataTable().fnDraw();
				}
			}
	    );
	}

	// 增加基站提交
	function save_station(obj){
		$.ajax({
			type:"POST",
			url:"station/add",
			data:obj,
			dataType :'json',
			timeout:"20000",
			success:function(data,textStatus){
				var msg = data.msg;
				var code = data.code;
				if(code == 0 && 'succ' == msg){
					alert("保存成功");
					$("#managerStation_div").modal("hide");
					$("#table_station").dataTable().fnDraw();
				}				
			},
			error : function(XMLResponse) {
				alert("提交超时请检查网络环境");
				$("#managerStation_div").modal("hide");
				$("#table_station").dataTable().fnDraw();
			}
		});
	}

	// 删除基站提交
	function delete_station(){
		$.post("station/deleteStationsById", {
			id : $("#station_id_delete").val()
		}, function(result) {
			if (result == -1) {
				alert("系统内部错误,请与管理员联系！");
				$("#deleteStation_div").modal("hide");
				$("#station_id_delete").val("");
				$("#table_station").dataTable().fnDraw();
			} else if (result == 0) {
				alert("删除基站成功！");
				$("#deleteStation_div").modal("hide");
				$("#station_id_delete").val("");
				$("#table_station").dataTable().fnDraw();
			}
		});
	}

	function clearInput() {
		$("#stationInfoTable input[type='text']").each(function(e) {
			$(this).val("");
		});
	}